home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 101-125 / disk_108 / monidcmp / monidcmp.doc < prev    next >
Text File  |  1992-05-06  |  13KB  |  262 lines

  1. OVERVIEW:
  2.  
  3. MonIDCMP lets you monitor the IntuiMessages that pass through any IDCMP
  4. window.  It prints the IntuiMessage class, mouse coordinates, qualifier
  5. values, and other useful information when appropriate.  For instance, if
  6. a GADGETDOWN message is reported, the GadgetID, GadgetType, GadgetFlags, and
  7. IntuiText are printed; if the gadget is a PROPGADGET, its Pot and Body values
  8. also are displayed.  This is a useful tool for debugging applications, for
  9. determining exactly what messages arrive and when, and for snooping into the
  10. inner workings of other programs.
  11.  
  12.  
  13. HOW TO USE MONIDCMP:
  14.  
  15. To use MonIDCMP you need to know the title of the window you want to monitor
  16. and the title of the screen where that window can be found.  Usually you can
  17. read the window title from the window itself.  If this is not possible,
  18. then use the command:
  19.  
  20.     1> MonIDCMP LIST WINDOWS
  21.  
  22. This will list each of the screens together with their associated windows. 
  23. The titles are enclosed in quotes so that any leading or training spaces are
  24. apparent.
  25.  
  26. Once you have identified the window and screen you want to use, you can begin
  27. monitoring it by typing MONIDCMP followed by the window name and screen title. 
  28. If either the window title or screen title includes spaces, then you should 
  29. put double quotes (") around it.  If the window is on the Workbench Screen, 
  30. then you don't need to specifiy the screen title.
  31.  
  32. For example, if you want to monitor the window called MyWindow on the Workbench
  33. Screen, then you should type
  34.  
  35.     1> MonIDCMP MyWindow "Workbench Screen"
  36.  
  37. or simply
  38.  
  39.     1> MonIDCMP MyWindow
  40.  
  41. To monitor the window called 'Input Window' on the screen 'Test Screen', type:
  42.  
  43.     1> MonIDCMP "Input Window" "Test Screen"
  44.  
  45. If MonIDCMP can't find the window or screen that you specified, it will tell
  46. you.  Use the MONIDCMP LIST WINDOWS command to get a list of windows that you
  47. can monitor.  The case of the letters does not matter (upper- and lower-case
  48. are treated as the same).
  49.  
  50. When MonIDCMP finds the window you specified, it will print its version number 
  51. and a message that tells you that the monitor is installed and how to stop
  52. it.  Once the monitor is installed, any IntuiMessages that arrive in the
  53. monitored window will be displayed in the CLI window.
  54.  
  55. When you are done using MonIDCMP, click in the CLI window where it is running
  56. and press CTRL-C.  MonIDCMP should tell you that it has stopped monitoring the
  57. window.
  58.  
  59. If MonIDCMP detects a CLOSEWINDOW IntuiMessage for the monitored window, it
  60. expects the window to close so it stops monitoring the window without your
  61. having to press CTRL-C.  Note that this ONLY occurs when a CLOSWINDOW message
  62. arrives.  If the window is closed for some other reason (e.g., you chose QUIT
  63. from a menu), MonIDCMP won't know about it, and you will have to cancel
  64. MonIDCMP using CTRL-C.
  65.  
  66.  
  67. OUTPUT RE-DIRECTION:
  68.  
  69. MonIDCMP can produce a lot of output which may move too fast for you to see,
  70. or you may want a permanent copy of the IDCMP activity saved for future
  71. reference.  In either of these cases, you can re-direct the output from
  72. MonIDCMP to a file (or to a printer) via the standard CLI command-line
  73. output re-direction.  For example:
  74.  
  75.     1> MonIDCMP >RAM:WB Workbench
  76.  
  77. would monitor the Workbench window (on the Workbench Screen) but send the
  78. output to the file RAM:WB.  Output re-direction can also be an important tool
  79. during situations that may cause deadlocks due to layer locking (see CAUTIONS
  80. below).
  81.  
  82.  
  83. EVENT MASKS:
  84.  
  85. Sometimes you are only interested in a particular type of IntuiMessage, for
  86. example, you may only want to know about gadget and mouse events even though
  87. the window is reporting menu picks, size changes and disk events as well.  To
  88. do this you use the MASK option of the MonIDCMP command.  The mask is the
  89. bitwise OR of all the IntuiMessage classes that you want to see.  For
  90. instance, GADGETUP is 0x40, GADGETDOWN is 0x20 and MOUSEBUTTONS is 0x8, so
  91. the mask we would use for our example above would be 0x68.  The mask value
  92. follows the word MASK on the command line and must precede the window name:
  93.  
  94.     1> MonIDCMP MASK 68 Workbench
  95.  
  96. The mask value is assumed to be in HEX.  The class codes are listed in the
  97. file intuition/intuition.h (right after the struct IntuiMessage definition).
  98.  
  99. Note that MonIDCMP does not alter the IDCMPFlags field of the monitored
  100. window, so the messages actually displayed will only be those that are in both 
  101. the MASK and the window's IDCMPFlags field.  MonIDCMP does not call 
  102. ModifyIDCMP() to include message additional classes that you specify in MASK.
  103.  
  104.  
  105. DISPLAY FORMATS:
  106.  
  107. MonIDCMP displays the message class, mouse coordinates and qualifiers (if any)
  108. for each message it receives.  The mouse coordinates are shown in decimal. 
  109. The qualifier field is shown in HEX, with translations of the important 
  110. bits (shift, ALT, CTRL and Amiga keys, key repeat, numeric pad, and button
  111. status; L means Left, R means Right, M means Middle (for future compatibility -
  112. see inputevent.h), and C means CapsLock).
  113.  
  114. The following classes include additional information:
  115.  
  116. Gadgets:  The GadgetID, gadget text (if any), GadgetType, and GadgetFlags are
  117. shown (the ID is in decimal, the flags are in HEX).  If the gadget is a
  118. STRGADGET, the data stored in the StringInfo buffer also is printed.  If the
  119. gadget is a PROPGADGET, the Pot and Body values are displayed (in decimal), as
  120. well as the KNOBHIT status, for the gadget's direction(s) of movement.
  121.  
  122. Menus:  The menu code is displayed and the translated MENUNUM, ITEMNUM and
  123. SUBNUM, as are the menu title, item text (if ITEMTEXT is set) and subitem text 
  124. (if ITEMTEXT is set).  If there were multiple menu-item selections during the
  125. menu pick (i.e., the user clicked the left button while still holding the
  126. right), these data are displayed for each item chosen.
  127.  
  128. Mouse Buttons:  SELECTUP, SELECTDOWN, MENUUP or MENUDOWN is displayed.
  129.  
  130. Raw Keys:  The raw key value is shown and whether the key was pressed or 
  131. released.  A simple translation to a keyboard key is performed and displayed. 
  132. Since the RAWKEY events include information for mapping dead keys (that
  133. produce diacritical markings), the previous key and qualifiers (if any) are
  134. displayed as well.
  135.  
  136. Vanilla Keys:  the ASCII code and character are displayed.
  137.  
  138.  
  139. TECHNICAL NOTES:
  140.  
  141. MonIDCMP works by taking over the monitored window's UserPort message port. 
  142. The message port structure includes (among other things) a pointer to a task
  143. to be signalled when a message arrives and a the signal number to use. 
  144. MonIDCMP substitutes a pointer to itself in the message port's mp_SigTask
  145. field so that it is signalled rather than the monitored process.  When
  146. MonIDCMP receives a signal from the message port, it traverses the list of
  147. messags that has arrived (stored in the mp_MsgList field, which is an Exec
  148. List of Exec Node structures which are at the tops of the IntuiMessages that
  149. have arrived in the UserPort) and prints the contents of the messages.  Once
  150. this is done, it calls Signal() to signal the original task that messages have
  151. arrived in the port.  That task then does normal GetMsg() and ReplyMsg() calls
  152. to get and reply to the messages, and is unaware that we "peeked" at the
  153. messages ahead of it.
  154.  
  155. New messages can arrive in the UserPort at any time, however, even when there
  156. are already messages there.  In order to prevent us from re-printing messages
  157. that we have already seen, we must mark the messages somehow so that we can
  158. distinguish new messaged from old ones.  To do this MonIDCMP sets the high bit
  159. in the ln_Type field (normally NT_MESSAGE) of the Node structure at the top of
  160. each IntuiMessage as it prints it.  This is kind of Kludgy, but it does not
  161. seem to annoy GetMsg() or ReplyMsg() or Intuition, so it seems a useful
  162. device.  The important point is that it is reset to NT_MESSAGE every time
  163. Intuition posts a new message, so even though Intuition re-uses the same
  164. memory areas for it's messages, our flag bit is reset automatically (this is
  165. not true of the other, un-used fields of the Node structure, so I had to use 
  166. the ln_Type field).
  167.  
  168. Another method would have been to take over the reply ports for each message
  169. as it came in, and reset the flags ourselves, but this seems needlessly
  170. complicated, and causes some other problems as well.
  171.  
  172. Once we signal the monitored task that messages are ready, it will read ALL
  173. the messages from the UserPort, including any that arrive while it is
  174. processing the others.  In order to prevent us from missing these messages, we
  175. must run at a higher priority than the monitored process; that way, even if
  176. the monitored process is running (i.e., it is not in a Wait() call), as soon
  177. as a new message arrives, we will pre-empt it and can process the new message
  178. without worrying about the other process taking it before we get the chance to
  179. see it.  MonIDCMP takes care of setting the priority so that it is one higher
  180. than that of the monitored process and resetting it when it is done.
  181.  
  182. Note that this method of monitoring message ports is not restricted to window
  183. UserPorts and IntuiMessages.  It can be used with any type of message port
  184. provided you know where to look for it and you know the formats of the
  185. messages it will contain.  The UserPort fits both these critera perfectly: 
  186. it is at a fixed position within the window structure (which we can find from
  187. screens, which we can find from IntuitionBase) and it has a well-defined
  188. set of messages that are easy to display.
  189.  
  190.  
  191. CAUTIONS:
  192.  
  193. More than one window in a screen can have the same name.  Currenly, MonIDCMP
  194. will monitor the FIRST window that matches the one you supply (here "first"
  195. means first as it is displayed by the MonIDCMP LIST WINDOWS command). 
  196. MonIDCMP does not provide a method for specifying other windows with the
  197. same name (you would have to close the first one in order to monitor the
  198. second, etc.).
  199.  
  200. Since MonIDCMP prints the contents of the messages BEFORE the monitored
  201. process can act on them, it is possible for MonIDCMP to cause a deadlock 
  202. situation.  For instance, suppose a program locks the screen's layers, and 
  203. then waits for mouse moves or a mouse button up message.  When MonIDCMP
  204. is signalled by one of these events, it attempts to display messages to that
  205. effect on the screen; but since the layers are locked, it can't do it, so it
  206. waits for the layers to be unlocked.  The program will not unlock the layers,
  207. however, until after it receives the button up message.  This produces a
  208. deadlock, and the two processes hang.  For example, this appears to be what 
  209. happens if you monitor the Workbench window and try to move a disk icon.
  210.  
  211. To get arround this problem, simply re-direct the MonIDCMP output into a
  212. file.  The locked layers will not inhibit writing to the file, so no deadlock
  213. will occur and processing can continue.  This is the only safe way to monitor
  214. the Workbench.
  215.  
  216. MonIDCMP relies on the fact that it runs at a higher priority than the process
  217. that it is monitoring.  This assures it that it will pre-empt the monitored
  218. process when new messages arrive, hence it will not be able to miss any
  219. messages.  If the monitored process calls Forbid() or Disable(), however, or 
  220. if it changes its priority, this may cause MonIDCMP to miss whole blocks of
  221. messages, particularly the kind that come in pairs (INACTIVEWINDOW and
  222. ACTIVEWINDOW, MENUUP and MENUPICK, etc).  Be careful when monitoring processes
  223. of this kind.
  224.  
  225. MonIDCMP can seriously impact program timing (i.e., double-click testing,
  226. PROPGADGET updating, etc).  Programs that use IntuiTicks for timing or that
  227. respond to MOUSEMOVE events will be slowed down considerably.  Color changing 
  228. sliders will react sluggishly, for instance.  Re-directing MonIDCMP output to 
  229. a RAM: file will help.
  230.  
  231. Note that this time dealy can cause a decrease in the amount of available free 
  232. memory.  If IntuiMessages are not replied to quickly enough, Intuition will 
  233. AllocMem() space for new ones as they arrive, but will not de-allocate them 
  234. until the window to which they were posted is closed.  This will happen when 
  235. lots of MOUSEMOVE events come in and MonIDCMP takes time to print them, for 
  236. instance.  To avoid this problem, use the MASK option to eliminate MOUSEMOVE 
  237. and INTUITICKS messages.
  238.  
  239.  
  240. COMPILING AND LINKING MONIDCMP:
  241.  
  242. I used Lattice C to produce MonIDCMP, but I tried to make it as compatible
  243. with Manx as possible.  I do not own the Manx compiler, however, so I can not
  244. test it out.  I suspect that any adjustments will be minor.
  245.  
  246. For Lattice C (v3.10) I just do:
  247.  
  248.     1> LC -L -dLATTICE MonIDCMP
  249.  
  250. That should do it.
  251.  
  252.  
  253. AUTHOR:
  254.  
  255. Davide P. Cervone
  256. University of Rochester Computing Center        DPVC@UORDBV.BITNET
  257. Taylor Hall                                     dpvc@tut.cc.rochester.EDU
  258. Rochester, New York                             dpvc@ur-tut.UUCP
  259. (716)275-2811
  260.  
  261. Copyright (c) 1987 by Davide P. Cervone, all rights reserved.
  262.